package com.lzxuni.modules.pestdetails.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzxuni.common.utils.StringUtils;
import com.lzxuni.modules.common.entity.PageParameter;
import com.lzxuni.modules.pestdetails.entity.PestCritical;
import com.lzxuni.modules.pestdetails.mapper.PestCriticalMapper;
import com.lzxuni.modules.pestdetails.service.PestCriticalService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 虫情管理--虫情状态临界值 服务实现类
 * </p>
 *
 * @author rdf
 * @since 2020-12-04
 */
@Service
public class PestCriticalServiceImpl extends ServiceImpl<PestCriticalMapper, PestCritical> implements PestCriticalService {

    @Override
    public PageInfo<PestCritical> queryPage(PageParameter pageParameter, PestCritical pestCritical) {
        if (StringUtils.isNotEmpty(pageParameter.getSidx())) {
            PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows()).setOrderBy(
                    pageParameter.getSidx() + " " + pageParameter.getSord());
        } else {
            PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows());
        }
        List<PestCritical> pestCriticallList = baseMapper.queryList(pestCritical);
        PageInfo<PestCritical> pageInfo = new PageInfo<>(pestCriticallList);
        return pageInfo;
    }
}
